<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%
	String basePath = request.getScheme()+"://"+request.getServerName()
		+ ":"+ request.getServerPort() + request.getContextPath() + "/";
%>
 
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>">
<meta charset="UTF-8">
<title>添加员工信息</title>
</head>
<body>
<h1>添加员工信息</h1>

<form action="emp/add.do" method="post" enctype="multipart/form-data">
姓名：<input type="text" name="ename"><br>
电话：<input type="text" name="ephone"><br>
部门：<select name="did">
</select><br>
生日：<input type="date" name="ebirthday"><br>
照片：<input type="file" name="file"><br>
<input type="submit" value="添加"><br>
${error }
</form>
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script type="text/javascript">
$.ajax({
	url:'dept/getAll.json',
	data:{},
	type:"POST",
	dataType:'JSON',
	success:function(data){
		
		// 解析 生成
		var html="";
		$.each(data,function(index,item){
			html += "<option value='"+item.did+"'>"+item.dname+"</option>";
		});
		$("select[name='did']").html(html);
		$("input[name='ebirthdar']").val(data.ebirthdar);
		
	},
	error:function(){
		console.log("请求失败")
	}
});
</script>

</body>
</html>